package com.example.pets_java.service;

import com.example.pets_java.mapper.PetMapper;
import com.example.pets_java.pojo.Pet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PetService {

    @Autowired
    private PetMapper petMapper;

    public List<Pet> getPetsByOwnerId(int ownerId) {
        return petMapper.findByOwnerId(ownerId);
    }

    public void addPet(Pet pet) {
        petMapper.insert(pet);
    }

    public void updatePet(Pet pet) {
        petMapper.update(pet);
    }

    public void deletePet(int id) {
        petMapper.delete(id);
    }

    public Pet getPetById(int id) {
        return petMapper.findById(id);
    }
}
